package flc.ast.fragment;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.blankj.utilcode.util.ArrayUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.stark.beat.lib.core.BeatSoundType;

import java.util.ArrayList;
import java.util.List;

import flc.ast.R;
import flc.ast.activity.MetronomeActivity;
import flc.ast.adapter.WalkBandAdapter;
import flc.ast.databinding.FragmentWalkBandBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link WalkBandFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class WalkBandFragment extends BaseNoModelFragment<FragmentWalkBandBinding> {

    private WalkBandAdapter walkBandAdapter;
    private List<BeatSoundType> beatSoundTypes;

    @Override
    protected int onCreate() {
        return R.layout.fragment_walk_band;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);
        mDataBinding.rvWalkBandList.setLayoutManager(new GridLayoutManager(mContext, 2));
        walkBandAdapter = new WalkBandAdapter();
        mDataBinding.rvWalkBandList.setAdapter(walkBandAdapter);
        walkBandAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        MetronomeActivity.sBeatSoundType = beatSoundTypes.get(position);
        startActivity(MetronomeActivity.class);
    }

    @Override
    protected void initData() {
        List<Integer> list = new ArrayList<>();
        list.add(R.drawable.yuansheng1);
        list.add(R.drawable.zhongjigu1);
        list.add(R.drawable.jiazigu1);
        list.add(R.drawable.kuaibansheng1);
        list.add(R.drawable.shizhongsheng1);
        list.add(R.drawable.qingqinsheng1);
        walkBandAdapter.setList(list);
        beatSoundTypes = ArrayUtils.asList(BeatSoundType.values());
    }
}